/**
 * Created on 2007-05-23 12:51
 */
package game.score;

import game.frames.HighscoreFrame;

/**
 * @author David Wallin
 */
public class Highscore
{
	/**
	 * Nanme of highscore keeper
	 */
	private String m_Name;
	/**
	 * The reached score
	 */
	private int m_Score;
	/**
	 * The reached level
	 */
	private int m_Level;
	/**
	 * The time if the highscore in sql format
	 */
	private String m_Timestamp;
	
	/**
	 * Default constructor, initializes members to 0
	 */
	public Highscore()
	{
		this("", 0, 0, "");
	}
	
	/**
	 * Constructor, initializes members
	 * 
	 * @param name The name of highscore keeper
	 * @param score The reached score
	 * @param level The reached level
	 * @param timestamp The time of the highscore in String format
	 */
	public Highscore(String name, int score, int level, String timestamp)
	{
		m_Name = name;
		m_Score = score;
		m_Level = level;
		m_Timestamp = timestamp;
	}
	
	/**
	 * @return the m_Level
	 */
	public int getLevel()
	{
		return m_Level;
	}
	
	/**
	 * @return the m_Name
	 */
	public String getName()
	{
		return m_Name;
	}
	
	/**
	 * @return the m_Score
	 */
	public int getScore()
	{
		return m_Score;
	}
	
	/**
	 * @return the m_Timestamp
	 */
	public String getTimestamp()
	{
		return m_Timestamp;
	}
	
	/**
	 * @param level the m_Level to set
	 */
	public void setLevel(int level)
	{
		m_Level = level;
	}
	
	/**
	 * @param name the m_Name to set
	 */
	public void setName(String name)
	{
		m_Name = name;
	}
	
	/**
	 * @param score the m_Score to set
	 */
	public void setScore(int score)
	{
		m_Score = score;
	}
	
	/**
	 * @param timestamp the m_Timestamp to set
	 */
	public void setTimestamp(String timestamp)
	{
		m_Timestamp = timestamp;
	}
	
	public String toString()
	{
		//TODO add advanced string concatenation
		String name = m_Name;
		
		if(name.length() > HighscoreFrame.MAX_NAME_LENGTH)
		{
			name = name.substring(0, HighscoreFrame.MAX_NAME_LENGTH);
		}
		
		return name + "\t" + m_Level + "\t" + m_Score + "\n";
	}
}
